// PeekPocket.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "PeekPocket.h"
#include "PPDlg.h"
#include "log.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CPeekPocketApp

BEGIN_MESSAGE_MAP(CPeekPocketApp, CWinApp)
END_MESSAGE_MAP()


// CPeekPocketApp construction
CPeekPocketApp::CPeekPocketApp()
	: CWinApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
	loginit();
}

CPeekPocketApp::~CPeekPocketApp()
{
	loguninit();
}


// The one and only CPeekPocketApp object
CPeekPocketApp theApp;

//program settings
CSettingsStorage g_Settings;

//language data
CTextCache g_Texts;

//AP data
CDataStorage g_APData;

//Wifi utilities
CWifiPeek g_WifiPeek;

// CPeekPocketApp initialization
BOOL CPeekPocketApp::InitInstance()
{
LanguagesEnum leLang;

	// SHInitExtraControls should be called once during your application's initialization to initialize any
    // of the Windows Mobile specific controls such as CAPEDIT and SIPPREF.
    SHInitExtraControls();

	// Standard initialization
	SetRegistryKey(_T("PeekPocket"));

	//read stored params
	g_Settings.Deserialize();

	g_Settings.GetNumeric(nseLanguage, (DWORD &)leLang);
	if(leLang < leEnglish || leLang >= leMAX)
	{
		leLang=leEnglish;
	}
	//read string table
	g_Texts.ReadStrings(leLang);

	CPPDlg dlg;

	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();

	//save settings back to registry
	g_Settings.Serialize();

	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	return TRUE;
}
